home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_7_3b.arc / PMDEV.ARC / PMAUX.C < prev    next >
C/C++ Source or Header  |  1989-01-19  |  2KB  |  92 lines

  1. /*
  2.  * PMAUX main module
  3.  *
  4.  * Written by Bill Hall
  5.  * 3665  Benton Street, #66
  6.  * Santa Clara, CA 95051
  7.  *
  8.  * See WPMAUX.DOC for usage information
  9.  *
  10.  */
  11.  
  12. #define INCL_PM
  13. #include <os2.h>
  14. #include <stddef.h>
  15. #include <string.h>
  16.  
  17. #include <ttycls.h>
  18. #define EXTERN            /* all globals are declared in this module */
  19. #include "pmaux.h"
  20.  
  21. /* entry point for program */
  22. int cdecl main(int argc, char *argv[])
  23. {
  24.  
  25.     QMSG qmsg;
  26.  
  27.   /* call initialization */
  28.     if (!InitProgram(argc, argv))
  29.     return FALSE;
  30.  
  31.   /* fall into message loop */
  32.     while (WinGetMsg(hAB, (PQMSG)&qmsg, (HWND)NULL, 0, 0))
  33.         WinDispatchMsg( hAB, (PQMSG)&qmsg );
  34.  
  35.   /* program exit */
  36.     WinDestroyWindow(hwndFrame);
  37.     WinDestroyMsgQueue(hmqMsgQ);
  38.     WinTerminate(hAB);
  39. }
  40.  
  41. /* main window message loop */
  42. MRESULT FAR PASCAL MainWndProc(HWND hWnd, USHORT msg, MPARAM mp1, MPARAM mp2)
  43. {
  44.  
  45.     HPS hPS;        /* handle to PM display context */
  46.     RECTL rect;
  47.  
  48.     switch (msg) {
  49.  
  50.     case WM_COMMAND:        /* process menu commands */
  51.         WndCommand(hWnd, LOUSHORT(mp1));
  52.         break;
  53.  
  54.     case WM_USER:        /* process message from calling window */
  55.         if (!WindowIsIconic(hWnd))
  56.             DispatchString(hWnd, mp1, mp2);
  57.         break;
  58.  
  59.     case WM_CREATE:        /* called when main window is created */
  60.         WndCreate(hWnd);
  61.         break;
  62.  
  63.     case WM_CLOSE:        /* called when main window is closed */
  64.         SetOS2Ini((HWND)NULL);
  65.         hPS = WinGetPS(hWnd);
  66.         GpiDeleteSetId(hPS, LCID_ALL);
  67.         WinReleasePS(hPS);
  68. #if IBMVER
  69.         GpiUnloadFonts(hAB, "c:\\os2\\dll\\COURIER.FON");
  70. #else
  71.         GpiLoadFonts(hAB, "FONTS");
  72. #endif
  73.             WinPostMsg(hWnd, WM_QUIT, 0L, 0L) ;
  74.             break;
  75.  
  76.        case WM_PAINT:        /* called when window needs repainting */
  77.         hPS = WinBeginPaint(hWnd, (HPS)NULL, (PRECTL)&rect);
  78.         MainWndPaint(hWnd, hPS, (short)rect.yTop, (short)rect.yBottom);
  79.         WinEndPaint( hPS );
  80.             break;
  81.  
  82.         case WM_ERASEBACKGROUND:    /* have PM take care of background */
  83.             return(TRUE);
  84.             break;
  85.  
  86.         default:        /* all other messages go here */
  87.             return( WinDefWindowProc( hWnd, msg, mp1, mp2 ) );
  88.             break;
  89.     }
  90.     return(0L);
  91. }
  92.